package com.itany.book.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itany.book.mapper.OrderMapper;
import com.itany.book.pojo.Order;
import com.itany.book.pojo.User;
import com.itany.book.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.awt.*;

/**
 * Author:yaozhiyuan0117@163.com
 * Time:2019/12/26 8:07
 * Describe:
 * version:1.0
 */

@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public PageInfo<Order> findAll(Integer page, Integer rows, String no, String alipayno) {
        PageHelper.startPage(page, rows);
        List<Order> orders =  orderMapper.selectByCondition(no, alipayno);
        PageInfo<Order> info = new PageInfo(orders);
        return info;
    }

    @Override
    public Order findById(Integer id) {
        return orderMapper.selectById(id);

    }

    @Override
    public void modifyOrder(Integer id, Integer flag) {
        orderMapper.updateOrder(id,flag);
    }
}
